#include <iostream>
#include <fstream>
#include "lexer.h"
#include "util.h"

using namespace NS_TIEC;

void lex_file() {
  FILE* file = fopen("../assets/test/android/StartUp.t", "r");
  reflex::Input input(file, reflex::Input::file_encoding::utf8);
  tiec::TiecodeLexer lexer(input);
  int token;
  while ((token = lexer.lex()) != TiecodeToken::Eof) {
    //printf("token: %d", token);
  }
}

void lex_string() {
  reflex::Input input("/*提示('哈')");
  tiec::TiecodeLexer lexer(input);
  int token;
  while ((token = lexer.lex()) != TiecodeToken::Eof) {
    //printf("token: %d", token);
  }
}

void test_uri() {
  String str = "https://www.baidu.com:2020/aaaa/aaaaaa?a=90&jj=0#b";
  Uri uri = Uri::fromString(str);
  std::cout << uri.asString() << std::endl;

  char* data = "aaa";
  ByteArray bytes = {data, sizeof(data) - 1};
  std::cout << toWString(bytes).data() << std::endl;
}

int main() {
  test_uri();
  /*
  std::ofstream out("out.txt");
  if (out.is_open()) {
    std::cout.rdbuf(out.rdbuf());
  }
  UInt64 start = TimeUtil::milliTime();
  for (int i = 0; i < 10; ++i) {
    lex_file();
  }
  std::cout << "lex 10 files time: " << (TimeUtil::milliTime() - start) << " ms" << std::endl;
  start = TimeUtil::milliTime();
  for (int i = 0; i < 200; ++i) {
    lex_file();
  }
  std::cout << "lex 200 files time: " << (TimeUtil::milliTime() - start) << " ms" << std::endl;*/
  return 0;
}